Problems with displaying results
Problems with displaying results
am 03.03.2009 17:16:05 von Terion Miller
--0016e644c5e68eadb4046439408a
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
I have two queries one pulls out which users to use and the second pulls
those users orders....
Looks something like this but is only pulling the first record:
$query = "SELECT `UserName`, `AdminID` FROM admin
WHERE Key1 = 'YES' ";
$result = mysql_query ($query) ;
$row = mysql_fetch_assoc($result);
//Reveal Variables for Debugging
// include("VariableReveal2.php");
echo ("Hello
");
//echo $row['AdminID'];
echo ($row['UserName']);
if ($row['Key1'] == "NO") {
header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
not have access to that page.");
}
if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
'WorkOrderID DESC';}
if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
$PerPage = 30;
$StartPage = ($Page - 1) * $PerPage;
second query here is using the $row from the first (and yes I know
not to use *, just did so here to keep post shorter)
$sql= "SELECT * FROM workorders WHERE AdminID =
'".$row['AdminID']."' ";
// $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
$result = mysql_query ($sql);
$row2 = mysql_fetch_assoc($result);
$Total = ceil(mysql_num_rows($result)/$PerPage);
So this works but only half way as it only displays the first record in
the table.
Thanks
Terion
Happy Freecycling
Free the List !!
www.freecycle.org
Over Moderation of Freecycle List Prevents Post Timeliness.
------------------------------------------------
Twitter?
http://twitter.com/terionmiller
------------------------------------------------
Facebook:
title="Terion Miller's Facebook profile" target=_TOP>
alt="Terion Miller's Facebook profile">
Groucho Marx - "I have had a perfectly wonderful evening, but this wasn't
it."
--0016e644c5e68eadb4046439408a--
Re: Problems with displaying results
am 03.03.2009 17:32:00 von Shawn McKenzie
Terion Miller wrote:
> I have two queries one pulls out which users to use and the second pulls
> those users orders....
> Looks something like this but is only pulling the first record:
>
>
> $query = "SELECT `UserName`, `AdminID` FROM admin
> WHERE Key1 = 'YES' ";
>
> $result = mysql_query ($query) ;
> $row = mysql_fetch_assoc($result);
>
> //Reveal Variables for Debugging
> // include("VariableReveal2.php");
> echo ("Hello
");
> //echo $row['AdminID'];
> echo ($row['UserName']);
>
>
>
>
> if ($row['Key1'] == "NO") {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> not have access to that page.");
> }
>
> if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
> 'WorkOrderID DESC';}
> if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
>
> $PerPage = 30;
> $StartPage = ($Page - 1) * $PerPage;
>
> second query here is using the $row from the first (and yes I know
> not to use *, just did so here to keep post shorter)
>
> $sql= "SELECT * FROM workorders WHERE AdminID =
> '".$row['AdminID']."' ";
> // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> $result = mysql_query ($sql);
> $row2 = mysql_fetch_assoc($result);
> $Total = ceil(mysql_num_rows($result)/$PerPage);
>
>
> So this works but only half way as it only displays the first record in
> the table.
>
>
>
>
> Thanks
> Terion
>
> Happy Freecycling
> Free the List !!
> www.freecycle.org
> Over Moderation of Freecycle List Prevents Post Timeliness.
> ------------------------------------------------
> Twitter?
> http://twitter.com/terionmiller
> ------------------------------------------------
> Facebook:
>
> title="Terion Miller's Facebook profile" target=_TOP>
> alt="Terion Miller's Facebook profile">
> Groucho Marx - "I have had a perfectly wonderful evening, but this wasn't
> it."
>
You need to lookup the mysql_fetch_assoc() function. It only returns
one row from a result set that may contain multiple rows. You need
something like:
while($row = mysql_fetch_assoc($result)) {
// do something with $row
}
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Problems with displaying results
am 03.03.2009 17:32:00 von Shawn McKenzie
Terion Miller wrote:
> I have two queries one pulls out which users to use and the second pulls
> those users orders....
> Looks something like this but is only pulling the first record:
>
>
> $query = "SELECT `UserName`, `AdminID` FROM admin
> WHERE Key1 = 'YES' ";
>
> $result = mysql_query ($query) ;
> $row = mysql_fetch_assoc($result);
>
> //Reveal Variables for Debugging
> // include("VariableReveal2.php");
> echo ("Hello
");
> //echo $row['AdminID'];
> echo ($row['UserName']);
>
>
>
>
> if ($row['Key1'] == "NO") {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> not have access to that page.");
> }
>
> if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
> 'WorkOrderID DESC';}
> if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
>
> $PerPage = 30;
> $StartPage = ($Page - 1) * $PerPage;
>
> second query here is using the $row from the first (and yes I know
> not to use *, just did so here to keep post shorter)
>
> $sql= "SELECT * FROM workorders WHERE AdminID =
> '".$row['AdminID']."' ";
> // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> $result = mysql_query ($sql);
> $row2 = mysql_fetch_assoc($result);
> $Total = ceil(mysql_num_rows($result)/$PerPage);
>
>
> So this works but only half way as it only displays the first record in
> the table.
>
>
>
>
> Thanks
> Terion
>
> Happy Freecycling
> Free the List !!
> www.freecycle.org
> Over Moderation of Freecycle List Prevents Post Timeliness.
> ------------------------------------------------
> Twitter?
> http://twitter.com/terionmiller
> ------------------------------------------------
> Facebook:
>
> title="Terion Miller's Facebook profile" target=_TOP>
> alt="Terion Miller's Facebook profile">
> Groucho Marx - "I have had a perfectly wonderful evening, but this wasn't
> it."
>
You need to lookup the mysql_fetch_assoc() function. It only returns
one row from a result set that may contain multiple rows. You need
something like:
while($row = mysql_fetch_assoc($result)) {
// do something with $row
}
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: Problems with displaying results
am 03.03.2009 18:00:24 von Kyle Terry
--00163646c41c074d49046439dfc5
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Tue, Mar 3, 2009 at 8:32 AM, Shawn McKenzie wrote:
> Terion Miller wrote:
> > I have two queries one pulls out which users to use and the second pulls
> > those users orders....
> > Looks something like this but is only pulling the first record:
> >
> >
> > $query = "SELECT `UserName`, `AdminID` FROM admin
> > WHERE Key1 = 'YES' ";
> >
> > $result = mysql_query ($query) ;
> > $row = mysql_fetch_assoc($result);
> >
> > //Reveal Variables for Debugging
> > // include("VariableReveal2.php");
> > echo ("Hello
");
> > //echo $row['AdminID'];
> > echo ($row['UserName']);
> >
> >
> >
> >
> > if ($row['Key1'] == "NO") {
> > header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> > not have access to that page.");
> > }
> >
> > if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
> > 'WorkOrderID DESC';}
> > if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
> >
> > $PerPage = 30;
> > $StartPage = ($Page - 1) * $PerPage;
> >
> > second query here is using the $row from the first (and yes I
> know
> > not to use *, just did so here to keep post shorter)
> >
> > $sql= "SELECT * FROM workorders WHERE AdminID =
> > '".$row['AdminID']."' ";
> > // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> > $result = mysql_query ($sql);
> > $row2 = mysql_fetch_assoc($result);
> > $Total = ceil(mysql_num_rows($result)/$PerPage);
> >
> >
> > So this works but only half way as it only displays the first record
> in
> > the table.
> >
> >
> >
> >
> > Thanks
> > Terion
> >
> > Happy Freecycling
> > Free the List !!
> > www.freecycle.org
> > Over Moderation of Freecycle List Prevents Post Timeliness.
> > ------------------------------------------------
> > Twitter?
> > http://twitter.com/terionmiller
> > ------------------------------------------------
> > Facebook:
> >
> > title="Terion Miller's Facebook profile" target=_TOP>
> > alt="Terion Miller's Facebook profile">
> > Groucho Marx - "I have had a perfectly wonderful evening, but this
> wasn't
> > it."
> >
>
> You need to lookup the mysql_fetch_assoc() function. It only returns
> one row from a result set that may contain multiple rows. You need
> something like:
>
> while($row = mysql_fetch_assoc($result)) {
> // do something with $row
> }
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> You also need to filter your user inputted data.
Kyle Terry | www.kyleterry.com
Help kick start VOOM (Very Open Object Model) for a library of PHP classes.
http://www.voom.me | IRC EFNet #voom
--00163646c41c074d49046439dfc5--
Re: Re: Problems with displaying results
am 03.03.2009 18:00:24 von Kyle Terry
--00163646c41c074d49046439dfc5
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Tue, Mar 3, 2009 at 8:32 AM, Shawn McKenzie wrote:
> Terion Miller wrote:
> > I have two queries one pulls out which users to use and the second pulls
> > those users orders....
> > Looks something like this but is only pulling the first record:
> >
> >
> > $query = "SELECT `UserName`, `AdminID` FROM admin
> > WHERE Key1 = 'YES' ";
> >
> > $result = mysql_query ($query) ;
> > $row = mysql_fetch_assoc($result);
> >
> > //Reveal Variables for Debugging
> > // include("VariableReveal2.php");
> > echo ("Hello
");
> > //echo $row['AdminID'];
> > echo ($row['UserName']);
> >
> >
> >
> >
> > if ($row['Key1'] == "NO") {
> > header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> > not have access to that page.");
> > }
> >
> > if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
> > 'WorkOrderID DESC';}
> > if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
> >
> > $PerPage = 30;
> > $StartPage = ($Page - 1) * $PerPage;
> >
> > second query here is using the $row from the first (and yes I
> know
> > not to use *, just did so here to keep post shorter)
> >
> > $sql= "SELECT * FROM workorders WHERE AdminID =
> > '".$row['AdminID']."' ";
> > // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> > $result = mysql_query ($sql);
> > $row2 = mysql_fetch_assoc($result);
> > $Total = ceil(mysql_num_rows($result)/$PerPage);
> >
> >
> > So this works but only half way as it only displays the first record
> in
> > the table.
> >
> >
> >
> >
> > Thanks
> > Terion
> >
> > Happy Freecycling
> > Free the List !!
> > www.freecycle.org
> > Over Moderation of Freecycle List Prevents Post Timeliness.
> > ------------------------------------------------
> > Twitter?
> > http://twitter.com/terionmiller
> > ------------------------------------------------
> > Facebook:
> >
> > title="Terion Miller's Facebook profile" target=_TOP>
> > alt="Terion Miller's Facebook profile">
> > Groucho Marx - "I have had a perfectly wonderful evening, but this
> wasn't
> > it."
> >
>
> You need to lookup the mysql_fetch_assoc() function. It only returns
> one row from a result set that may contain multiple rows. You need
> something like:
>
> while($row = mysql_fetch_assoc($result)) {
> // do something with $row
> }
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> You also need to filter your user inputted data.
Kyle Terry | www.kyleterry.com
Help kick start VOOM (Very Open Object Model) for a library of PHP classes.
http://www.voom.me | IRC EFNet #voom
--00163646c41c074d49046439dfc5--
Re: Re: Problems with displaying results
am 03.03.2009 18:08:27 von Terion Miller
--001485f86f4ece2eb2046439fb59
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Tue, Mar 3, 2009 at 10:32 AM, Shawn McKenzie wrote:
> Terion Miller wrote:
> > I have two queries one pulls out which users to use and the second pulls
> > those users orders....
> > Looks something like this but is only pulling the first record:
> >
> >
> > $query = "SELECT `UserName`, `AdminID` FROM admin
> > WHERE Key1 = 'YES' ";
> >
> > $result = mysql_query ($query) ;
> > $row = mysql_fetch_assoc($result);
> >
> > //Reveal Variables for Debugging
> > // include("VariableReveal2.php");
> > echo ("Hello
");
> > //echo $row['AdminID'];
> > echo ($row['UserName']);
> >
> >
> >
> >
> > if ($row['Key1'] == "NO") {
> > header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> > not have access to that page.");
> > }
> >
> > if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
> > 'WorkOrderID DESC';}
> > if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
> >
> > $PerPage = 30;
> > $StartPage = ($Page - 1) * $PerPage;
> >
> > second query here is using the $row from the first (and yes I
> know
> > not to use *, just did so here to keep post shorter)
> >
> > $sql= "SELECT * FROM workorders WHERE AdminID =
> > '".$row['AdminID']."' ";
> > // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> > $result = mysql_query ($sql);
> > $row2 = mysql_fetch_assoc($result);
> > $Total = ceil(mysql_num_rows($result)/$PerPage);
> >
> >
> > So this works but only half way as it only displays the first record
> in
> > the table.
> >
> >
> >
> >
> > Thanks
> > Terion
> >
> > Happy Freecycling
> > Free the List !!
> > www.freecycle.org
> > Over Moderation of Freecycle List Prevents Post Timeliness.
> > ------------------------------------------------
> > Twitter?
> > http://twitter.com/terionmiller
> > ------------------------------------------------
> > Facebook:
> >
> > title="Terion Miller's Facebook profile" target=_TOP>
> > alt="Terion Miller's Facebook profile">
> > Groucho Marx - "I have had a perfectly wonderful evening, but this
> wasn't
> > it."
> >
>
> You need to lookup the mysql_fetch_assoc() function. It only returns
> one row from a result set that may contain multiple rows. You need
> something like:
>
> while($row = mysql_fetch_assoc($result)) {
> // do something with $row
> }
>
> ---------------------------------------------------
well I looked it up in my book and tried this example but still get the same
thing, the first record
$result = mysql_query ($query) ;
//$row = mysql_fetch_array($result);
while ($row = mysql_fetch_row($result)){
for ($i=0; $i
echo $row[$i] . " ";
//print a return for neatness sake
echo "\n";
--001485f86f4ece2eb2046439fb59--
Re: Re: Problems with displaying results
am 03.03.2009 18:08:27 von Terion Miller
--001485f86f4ece2eb2046439fb59
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Tue, Mar 3, 2009 at 10:32 AM, Shawn McKenzie wrote:
> Terion Miller wrote:
> > I have two queries one pulls out which users to use and the second pulls
> > those users orders....
> > Looks something like this but is only pulling the first record:
> >
> >
> > $query = "SELECT `UserName`, `AdminID` FROM admin
> > WHERE Key1 = 'YES' ";
> >
> > $result = mysql_query ($query) ;
> > $row = mysql_fetch_assoc($result);
> >
> > //Reveal Variables for Debugging
> > // include("VariableReveal2.php");
> > echo ("Hello
");
> > //echo $row['AdminID'];
> > echo ($row['UserName']);
> >
> >
> >
> >
> > if ($row['Key1'] == "NO") {
> > header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> > not have access to that page.");
> > }
> >
> > if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
> > 'WorkOrderID DESC';}
> > if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
> >
> > $PerPage = 30;
> > $StartPage = ($Page - 1) * $PerPage;
> >
> > second query here is using the $row from the first (and yes I
> know
> > not to use *, just did so here to keep post shorter)
> >
> > $sql= "SELECT * FROM workorders WHERE AdminID =
> > '".$row['AdminID']."' ";
> > // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> > $result = mysql_query ($sql);
> > $row2 = mysql_fetch_assoc($result);
> > $Total = ceil(mysql_num_rows($result)/$PerPage);
> >
> >
> > So this works but only half way as it only displays the first record
> in
> > the table.
> >
> >
> >
> >
> > Thanks
> > Terion
> >
> > Happy Freecycling
> > Free the List !!
> > www.freecycle.org
> > Over Moderation of Freecycle List Prevents Post Timeliness.
> > ------------------------------------------------
> > Twitter?
> > http://twitter.com/terionmiller
> > ------------------------------------------------
> > Facebook:
> >
> > title="Terion Miller's Facebook profile" target=_TOP>
> > alt="Terion Miller's Facebook profile">
> > Groucho Marx - "I have had a perfectly wonderful evening, but this
> wasn't
> > it."
> >
>
> You need to lookup the mysql_fetch_assoc() function. It only returns
> one row from a result set that may contain multiple rows. You need
> something like:
>
> while($row = mysql_fetch_assoc($result)) {
> // do something with $row
> }
>
> ---------------------------------------------------
well I looked it up in my book and tried this example but still get the same
thing, the first record
$result = mysql_query ($query) ;
//$row = mysql_fetch_array($result);
while ($row = mysql_fetch_row($result)){
for ($i=0; $i
echo $row[$i] . " ";
//print a return for neatness sake
echo "\n";
--001485f86f4ece2eb2046439fb59--
Re: Re: [PHP-DB] Re: Problems with displaying results
am 03.03.2009 21:16:45 von Ashley Sheridan
On Tue, 2009-03-03 at 11:08 -0600, Terion Miller wrote:
> On Tue, Mar 3, 2009 at 10:32 AM, Shawn McKenzie wrote:
>
> > Terion Miller wrote:
> > > I have two queries one pulls out which users to use and the second pulls
> > > those users orders....
> > > Looks something like this but is only pulling the first record:
> > >
> > >
> > > $query = "SELECT `UserName`, `AdminID` FROM admin
> > > WHERE Key1 = 'YES' ";
> > >
> > > $result = mysql_query ($query) ;
> > > $row = mysql_fetch_assoc($result);
> > >
> > > //Reveal Variables for Debugging
> > > // include("VariableReveal2.php");
> > > echo ("Hello
");
> > > //echo $row['AdminID'];
> > > echo ($row['UserName']);
> > >
> > >
> > >
> > >
> > > if ($row['Key1'] == "NO") {
> > > header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> > > not have access to that page.");
> > > }
> > >
> > > if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
> > > 'WorkOrderID DESC';}
> > > if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
> > >
> > > $PerPage = 30;
> > > $StartPage = ($Page - 1) * $PerPage;
> > >
> > > second query here is using the $row from the first (and yes I
> > know
> > > not to use *, just did so here to keep post shorter)
> > >
> > > $sql= "SELECT * FROM workorders WHERE AdminID =
> > > '".$row['AdminID']."' ";
> > > // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> > > $result = mysql_query ($sql);
> > > $row2 = mysql_fetch_assoc($result);
> > > $Total = ceil(mysql_num_rows($result)/$PerPage);
> > >
> > >
> > > So this works but only half way as it only displays the first record
> > in
> > > the table.
> > >
> > >
> > >
> > >
> > > Thanks
> > > Terion
> > >
> > > Happy Freecycling
> > > Free the List !!
> > > www.freecycle.org
> > > Over Moderation of Freecycle List Prevents Post Timeliness.
> > > ------------------------------------------------
> > > Twitter?
> > > http://twitter.com/terionmiller
> > > ------------------------------------------------
> > > Facebook:
> > >
> > > title="Terion Miller's Facebook profile" target=_TOP>
> > > alt="Terion Miller's Facebook profile">
> > > Groucho Marx - "I have had a perfectly wonderful evening, but this
> > wasn't
> > > it."
> > >
> >
> > You need to lookup the mysql_fetch_assoc() function. It only returns
> > one row from a result set that may contain multiple rows. You need
> > something like:
> >
> > while($row = mysql_fetch_assoc($result)) {
> > // do something with $row
> > }
> >
> > ---------------------------------------------------
>
> well I looked it up in my book and tried this example but still get the same
> thing, the first record
>
> $result = mysql_query ($query) ;
> //$row = mysql_fetch_array($result);
> while ($row = mysql_fetch_row($result)){
> for ($i=0; $i
> echo $row[$i] . " ";
> //print a return for neatness sake
> echo "\n";
What happens if you just change your while loop to this:
while($row = mysql_fetch_array($result))
{
print_r($row);
}
Ash
www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP-DB] Re: Problems with displaying results
am 03.03.2009 21:16:45 von Ashley Sheridan
On Tue, 2009-03-03 at 11:08 -0600, Terion Miller wrote:
> On Tue, Mar 3, 2009 at 10:32 AM, Shawn McKenzie wrote:
>
> > Terion Miller wrote:
> > > I have two queries one pulls out which users to use and the second pulls
> > > those users orders....
> > > Looks something like this but is only pulling the first record:
> > >
> > >
> > > $query = "SELECT `UserName`, `AdminID` FROM admin
> > > WHERE Key1 = 'YES' ";
> > >
> > > $result = mysql_query ($query) ;
> > > $row = mysql_fetch_assoc($result);
> > >
> > > //Reveal Variables for Debugging
> > > // include("VariableReveal2.php");
> > > echo ("Hello
");
> > > //echo $row['AdminID'];
> > > echo ($row['UserName']);
> > >
> > >
> > >
> > >
> > > if ($row['Key1'] == "NO") {
> > > header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> > > not have access to that page.");
> > > }
> > >
> > > if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
> > > 'WorkOrderID DESC';}
> > > if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
> > >
> > > $PerPage = 30;
> > > $StartPage = ($Page - 1) * $PerPage;
> > >
> > > second query here is using the $row from the first (and yes I
> > know
> > > not to use *, just did so here to keep post shorter)
> > >
> > > $sql= "SELECT * FROM workorders WHERE AdminID =
> > > '".$row['AdminID']."' ";
> > > // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> > > $result = mysql_query ($sql);
> > > $row2 = mysql_fetch_assoc($result);
> > > $Total = ceil(mysql_num_rows($result)/$PerPage);
> > >
> > >
> > > So this works but only half way as it only displays the first record
> > in
> > > the table.
> > >
> > >
> > >
> > >
> > > Thanks
> > > Terion
> > >
> > > Happy Freecycling
> > > Free the List !!
> > > www.freecycle.org
> > > Over Moderation of Freecycle List Prevents Post Timeliness.
> > > ------------------------------------------------
> > > Twitter?
> > > http://twitter.com/terionmiller
> > > ------------------------------------------------
> > > Facebook:
> > >
> > > title="Terion Miller's Facebook profile" target=_TOP>
> > > alt="Terion Miller's Facebook profile">
> > > Groucho Marx - "I have had a perfectly wonderful evening, but this
> > wasn't
> > > it."
> > >
> >
> > You need to lookup the mysql_fetch_assoc() function. It only returns
> > one row from a result set that may contain multiple rows. You need
> > something like:
> >
> > while($row = mysql_fetch_assoc($result)) {
> > // do something with $row
> > }
> >
> > ---------------------------------------------------
>
> well I looked it up in my book and tried this example but still get the same
> thing, the first record
>
> $result = mysql_query ($query) ;
> //$row = mysql_fetch_array($result);
> while ($row = mysql_fetch_row($result)){
> for ($i=0; $i
> echo $row[$i] . " ";
> //print a return for neatness sake
> echo "\n";
What happens if you just change your while loop to this:
while($row = mysql_fetch_array($result))
{
print_r($row);
}
Ash
www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DB] Re: Problems with displaying results
am 05.03.2009 16:30:22 von Terion Miller
--0016e644cc2abd935d046460d829
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Tue, Mar 3, 2009 at 2:16 PM, Ashley Sheridan wrote:
> On Tue, 2009-03-03 at 11:08 -0600, Terion Miller wrote:
> > On Tue, Mar 3, 2009 at 10:32 AM, Shawn McKenzie
> >wrote:
> >
> > > Terion Miller wrote:
> > > > I have two queries one pulls out which users to use and the second
> pulls
> > > > those users orders....
> > > > Looks something like this but is only pulling the first record:
> > > >
> > > >
> > > > $query = "SELECT `UserName`, `AdminID` FROM admin
> > > > WHERE Key1 = 'YES' ";
> > > >
> > > > $result = mysql_query ($query) ;
> > > > $row = mysql_fetch_assoc($result);
> > > >
> > > > //Reveal Variables for Debugging
> > > > // include("VariableReveal2.php");
> > > > echo ("Hello
");
> > > > //echo $row['AdminID'];
> > > > echo ($row['UserName']);
> > > >
> > > >
> > > >
> > > >
> > > > if ($row['Key1'] == "NO") {
> > > > header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry,
> you do
> > > > not have access to that page.");
> > > > }
> > > >
> > > > if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else
> {$SortBy =
> > > > 'WorkOrderID DESC';}
> > > > if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
> > > >
> > > > $PerPage = 30;
> > > > $StartPage = ($Page - 1) * $PerPage;
> > > >
> > > > second query here is using the $row from the first (and yes I
> > > know
> > > > not to use *, just did so here to keep post shorter)
> > > >
> > > > $sql= "SELECT * FROM workorders WHERE AdminID =
> > > > '".$row['AdminID']."' ";
> > > > // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> > > > $result = mysql_query ($sql);
> > > > $row2 = mysql_fetch_assoc($result);
> > > > $Total = ceil(mysql_num_rows($result)/$PerPage);
> > > >
> > > >
> > > > So this works but only half way as it only displays the first
> record
> > > in
> > > > the table.
> > > >
> > > >
> > > >
> > > >
> > > > Thanks
> > > > Terion
> > > >
> > > > Happy Freecycling
> > > > Free the List !!
> > > > www.freecycle.org
> > > > Over Moderation of Freecycle List Prevents Post Timeliness.
> > > > ------------------------------------------------
> > > > Twitter?
> > > > http://twitter.com/terionmiller
> > > > ------------------------------------------------
> > > > Facebook:
> > > >
> > > > title="Terion Miller's Facebook profile" target=_TOP>
> border=0
> > > > alt="Terion Miller's Facebook profile">
> > > > Groucho Marx - "I have had a perfectly wonderful evening, but this
> > > wasn't
> > > > it."
> > > >
> > >
> > > You need to lookup the mysql_fetch_assoc() function. It only returns
> > > one row from a result set that may contain multiple rows. You need
> > > something like:
> > >
> > > while($row = mysql_fetch_assoc($result)) {
> > > // do something with $row
> > > }
> > >
> > > ---------------------------------------------------
> >
> > well I looked it up in my book and tried this example but still get the
> same
> > thing, the first record
> >
> > $result = mysql_query ($query) ;
> > //$row = mysql_fetch_array($result);
> > while ($row = mysql_fetch_row($result)){
> > for ($i=0; $i
> > echo $row[$i] . " ";
> > //print a return for neatness sake
> > echo "\n";
> What happens if you just change your while loop to this:
>
> while($row = mysql_fetch_array($result))
> {
> print_r($row);
> }
>
>
> Ash
> www.ashleysheridan.co.uk
>
> Still having problems with getting this script to work, the first part of
the query does now work since I used the suggested JOIN, so my results are
there and I can echo them but now I can't seem to get them to display neatly
somehow:
--------------------CODE THUS
FAR--------------------------------------------
$query = "SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
workorders.CreatedDate, workorders.Location, workorders.WorkOrderName,
workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
WHERE admin.Retail1 = 'yes'
";
$result = mysql_query ($query) ;
//$row = mysql_fetch_array($result);
while ($row = mysql_fetch_row($result)){
$admin_id = $row['AdminID'];
for ($i=0; $i
//echo $row[$i] . " ";
}
if ($row['Retail1'] == "NO") {
header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
not have access to that page.");
}
if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
'WorkOrderID DESC';}
if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
$PerPage = 30;
$StartPage = ($Page - 1) * $PerPage;
$sql= "SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID =
'".$row['AdminID']."' ";
$query .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
$result=mysql_query($query) or die('Queryproblem: ' . mysql_error() .
'
Executed query: ' . $query);
$row2 = mysql_fetch_assoc($result);
while ($row2 = mysql_fetch_row($result)) {
// for ($i=0; $i
$Total = ceil(mysql_num_rows($result)/$PerPage);
}
//Reveal Variables for Debugging
include("VariableReveal2.php"); this is interesting too because this
variable reveal script shows that row2 has nothing in it, and really I don't
need the second query but I don't know how to use the seperate fields in the
$row['$i'] I tried doing things like echo $i['AdminID'] and got nothing...
------------------------------------------------------------ -----------------------------------------------------------
here is what the variable view returns:
$query"SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
workorders.CreatedDate, workorders.Location, workorders.WorkOrderName,
workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
WHERE admin.Retail1 = 'yes' ORDER BY WorkOrderID DESC LIMIT 0,
30"$result"Resource
id #5"$row""$admin_id""$i"10"this does print out all 10 records if echo
$row['$i'] is used$SortBy"WorkOrderID DESC"$Page"1"$PerPage"30"$StartPage"0"
$sql"SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID,
FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '' "$row2""
$Total"1"
--0016e644cc2abd935d046460d829--
Re: [PHP] Re: [PHP-DB] Re: Problems with displaying results
am 05.03.2009 16:30:22 von Terion Miller
--0016e644cc2abd935d046460d829
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Tue, Mar 3, 2009 at 2:16 PM, Ashley Sheridan wrote:
> On Tue, 2009-03-03 at 11:08 -0600, Terion Miller wrote:
> > On Tue, Mar 3, 2009 at 10:32 AM, Shawn McKenzie
> >wrote:
> >
> > > Terion Miller wrote:
> > > > I have two queries one pulls out which users to use and the second
> pulls
> > > > those users orders....
> > > > Looks something like this but is only pulling the first record:
> > > >
> > > >
> > > > $query = "SELECT `UserName`, `AdminID` FROM admin
> > > > WHERE Key1 = 'YES' ";
> > > >
> > > > $result = mysql_query ($query) ;
> > > > $row = mysql_fetch_assoc($result);
> > > >
> > > > //Reveal Variables for Debugging
> > > > // include("VariableReveal2.php");
> > > > echo ("Hello
");
> > > > //echo $row['AdminID'];
> > > > echo ($row['UserName']);
> > > >
> > > >
> > > >
> > > >
> > > > if ($row['Key1'] == "NO") {
> > > > header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry,
> you do
> > > > not have access to that page.");
> > > > }
> > > >
> > > > if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else
> {$SortBy =
> > > > 'WorkOrderID DESC';}
> > > > if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
> > > >
> > > > $PerPage = 30;
> > > > $StartPage = ($Page - 1) * $PerPage;
> > > >
> > > > second query here is using the $row from the first (and yes I
> > > know
> > > > not to use *, just did so here to keep post shorter)
> > > >
> > > > $sql= "SELECT * FROM workorders WHERE AdminID =
> > > > '".$row['AdminID']."' ";
> > > > // $sql .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
> > > > $result = mysql_query ($sql);
> > > > $row2 = mysql_fetch_assoc($result);
> > > > $Total = ceil(mysql_num_rows($result)/$PerPage);
> > > >
> > > >
> > > > So this works but only half way as it only displays the first
> record
> > > in
> > > > the table.
> > > >
> > > >
> > > >
> > > >
> > > > Thanks
> > > > Terion
> > > >
> > > > Happy Freecycling
> > > > Free the List !!
> > > > www.freecycle.org
> > > > Over Moderation of Freecycle List Prevents Post Timeliness.
> > > > ------------------------------------------------
> > > > Twitter?
> > > > http://twitter.com/terionmiller
> > > > ------------------------------------------------
> > > > Facebook:
> > > >
> > > > title="Terion Miller's Facebook profile" target=_TOP>
> border=0
> > > > alt="Terion Miller's Facebook profile">
> > > > Groucho Marx - "I have had a perfectly wonderful evening, but this
> > > wasn't
> > > > it."
> > > >
> > >
> > > You need to lookup the mysql_fetch_assoc() function. It only returns
> > > one row from a result set that may contain multiple rows. You need
> > > something like:
> > >
> > > while($row = mysql_fetch_assoc($result)) {
> > > // do something with $row
> > > }
> > >
> > > ---------------------------------------------------
> >
> > well I looked it up in my book and tried this example but still get the
> same
> > thing, the first record
> >
> > $result = mysql_query ($query) ;
> > //$row = mysql_fetch_array($result);
> > while ($row = mysql_fetch_row($result)){
> > for ($i=0; $i
> > echo $row[$i] . " ";
> > //print a return for neatness sake
> > echo "\n";
> What happens if you just change your while loop to this:
>
> while($row = mysql_fetch_array($result))
> {
> print_r($row);
> }
>
>
> Ash
> www.ashleysheridan.co.uk
>
> Still having problems with getting this script to work, the first part of
the query does now work since I used the suggested JOIN, so my results are
there and I can echo them but now I can't seem to get them to display neatly
somehow:
--------------------CODE THUS
FAR--------------------------------------------
$query = "SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
workorders.CreatedDate, workorders.Location, workorders.WorkOrderName,
workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
WHERE admin.Retail1 = 'yes'
";
$result = mysql_query ($query) ;
//$row = mysql_fetch_array($result);
while ($row = mysql_fetch_row($result)){
$admin_id = $row['AdminID'];
for ($i=0; $i
//echo $row[$i] . " ";
}
if ($row['Retail1'] == "NO") {
header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
not have access to that page.");
}
if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy =
'WorkOrderID DESC';}
if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;}
$PerPage = 30;
$StartPage = ($Page - 1) * $PerPage;
$sql= "SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID =
'".$row['AdminID']."' ";
$query .= "ORDER BY $SortBy LIMIT $StartPage, $PerPage";
$result=mysql_query($query) or die('Queryproblem: ' . mysql_error() .
'
Executed query: ' . $query);
$row2 = mysql_fetch_assoc($result);
while ($row2 = mysql_fetch_row($result)) {
// for ($i=0; $i
$Total = ceil(mysql_num_rows($result)/$PerPage);
}
//Reveal Variables for Debugging
include("VariableReveal2.php"); this is interesting too because this
variable reveal script shows that row2 has nothing in it, and really I don't
need the second query but I don't know how to use the seperate fields in the
$row['$i'] I tried doing things like echo $i['AdminID'] and got nothing...
------------------------------------------------------------ -----------------------------------------------------------
here is what the variable view returns:
$query"SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
workorders.CreatedDate, workorders.Location, workorders.WorkOrderName,
workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
WHERE admin.Retail1 = 'yes' ORDER BY WorkOrderID DESC LIMIT 0,
30"$result"Resource
id #5"$row""$admin_id""$i"10"this does print out all 10 records if echo
$row['$i'] is used$SortBy"WorkOrderID DESC"$Page"1"$PerPage"30"$StartPage"0"
$sql"SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID,
FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '' "$row2""
$Total"1"
--0016e644cc2abd935d046460d829--
Re: [PHP-DB] Re: [PHP] Re: [PHP-DB] Re: Problems with displaying
am 05.03.2009 18:25:24 von Lex Braun
--0015175cba621a24a904646274c5
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Thu, Mar 5, 2009 at 10:30 AM, Terion Miller wrote:
> Still having problems with getting this script to work, the first part of
> the query does now work since I used the suggested JOIN, so my results are
> there and I can echo them but now I can't seem to get them to display
> neatly
> somehow:
>
> --------------------CODE THUS
> FAR--------------------------------------------
> $query = "SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
> workorders.CreatedDate, workorders.Location, workorders.WorkOrderName,
> workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
> FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
> WHERE admin.Retail1 = 'yes'
> ";
>
> $result = mysql_query ($query) ;
> //$row = mysql_fetch_array($result);
> while ($row = mysql_fetch_row($result)){
> $admin_id = $row['AdminID'];
mysql_fetch_row() returns a numerical array (
http://ca2.php.net/manual/en/function.mysql-fetch-row.php), but then you are
trying to assign $admin_id using an associative array. Thus, you need to
either return your row as an associative array (
http://ca2.php.net/manual/en/function.mysql-fetch-assoc.php) or assign
$admin_id as a numerical array:
Method 1: Use a numerical array
$result = mysql_query($query);
while($row = mysql_fetch_row($result)) {
$admin_id = $row[1]; // since it's the 2nd item in your SELECT
...
}
OR
Method 2: Use an associative array
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) { // returns result row as an
associative array
$admin_id = $row['AdminID'];
....
}
--0015175cba621a24a904646274c5--
Re: [PHP-DB] Re: [PHP] Re: [PHP-DB] Re: Problems with displaying
am 05.03.2009 18:25:24 von Lex Braun
--0015175cba621a24a904646274c5
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Thu, Mar 5, 2009 at 10:30 AM, Terion Miller wrote:
> Still having problems with getting this script to work, the first part of
> the query does now work since I used the suggested JOIN, so my results are
> there and I can echo them but now I can't seem to get them to display
> neatly
> somehow:
>
> --------------------CODE THUS
> FAR--------------------------------------------
> $query = "SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
> workorders.CreatedDate, workorders.Location, workorders.WorkOrderName,
> workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
> FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
> WHERE admin.Retail1 = 'yes'
> ";
>
> $result = mysql_query ($query) ;
> //$row = mysql_fetch_array($result);
> while ($row = mysql_fetch_row($result)){
> $admin_id = $row['AdminID'];
mysql_fetch_row() returns a numerical array (
http://ca2.php.net/manual/en/function.mysql-fetch-row.php), but then you are
trying to assign $admin_id using an associative array. Thus, you need to
either return your row as an associative array (
http://ca2.php.net/manual/en/function.mysql-fetch-assoc.php) or assign
$admin_id as a numerical array:
Method 1: Use a numerical array
$result = mysql_query($query);
while($row = mysql_fetch_row($result)) {
$admin_id = $row[1]; // since it's the 2nd item in your SELECT
...
}
OR
Method 2: Use an associative array
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) { // returns result row as an
associative array
$admin_id = $row['AdminID'];
....
}
--0015175cba621a24a904646274c5--
(SOLVEDV) Re: Problems with displaying results
am 05.03.2009 21:34:05 von Terion Miller
--0016e644cdd6e8523904646516c4
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Thanks everyone it was the WHILE I just moved the ending bracket and presto
results show in tables...
Thanks
Terion
Happy Freecycling
Free the List !!
www.freecycle.org
Over Moderation of Freecycle List Prevents Post Timeliness.
------------------------------------------------
Twitter?
http://twitter.com/terionmiller
------------------------------------------------
Facebook:
title="Terion Miller's Facebook profile" target=_TOP>
alt="Terion Miller's Facebook profile">
Carl Sagan - "In order to make an apple pie from scratch, you must first
create the universe."
On Thu, Mar 5, 2009 at 11:25 AM, Lex Braun wrote:
>
> On Thu, Mar 5, 2009 at 10:30 AM, Terion Miller wrote:
>
>> Still having problems with getting this script to work, the first part of
>> the query does now work since I used the suggested JOIN, so my results are
>> there and I can echo them but now I can't seem to get them to display
>> neatly
>> somehow:
>>
>> --------------------CODE THUS
>> FAR--------------------------------------------
>> $query = "SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
>> workorders.CreatedDate, workorders.Location, workorders.WorkOrderName,
>> workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
>> FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
>> WHERE admin.Retail1 = 'yes'
>> ";
>>
>> $result = mysql_query ($query) ;
>> //$row = mysql_fetch_array($result);
>> while ($row = mysql_fetch_row($result)){
>> $admin_id = $row['AdminID'];
>
>
> mysql_fetch_row() returns a numerical array (
> http://ca2.php.net/manual/en/function.mysql-fetch-row.php), but then you
> are trying to assign $admin_id using an associative array. Thus, you need to
> either return your row as an associative array (
> http://ca2.php.net/manual/en/function.mysql-fetch-assoc.php) or assign
> $admin_id as a numerical array:
>
> Method 1: Use a numerical array
> $result = mysql_query($query);
> while($row = mysql_fetch_row($result)) {
> $admin_id = $row[1]; // since it's the 2nd item in your SELECT
> ...
> }
>
> OR
>
> Method 2: Use an associative array
> $result = mysql_query($query);
> while($row = mysql_fetch_assoc($result)) { // returns result row as an
> associative array
> $admin_id = $row['AdminID'];
> ....
> }
>
--0016e644cdd6e8523904646516c4--